import React, { Component } from 'react';
import styles from './style.scss';
import { DatePicker } from 'antd';

class DatePickers extends Component {
    render() {
        const locale = {
            lang: {
                backToToday: '返回今天',
                clear: '清除',
                dateFormat: 'YYYY年M月D日',
                dateSelect: '选择日期',
                dateTimeFormat: 'YYYY年M月D日 HH时mm分ss秒',
                dayFormat: 'D日',
                decadeSelect: '选择年代',
                month: '月',
                monthSelect: '选择月份',
                nextCentury: '下一世纪',
                nextDecade: '下一年代',
                nextMonth: '下个月 (翻页下键)',
                nextYear: '下一年 (Control键加右方向键)',
                now: '当前时间',
                ok: '确定',
                placeholder: '',
                previousCentury: '上一世纪',
                previousDecade: '上一年代',
                previousMonth: '上个月 (翻页上键)',
                previousYear: '上一年 (Control键加左方向键)',
                rangePlaceholder: ['开始日期', '结束日期'],
                timeSelect: '选择时间',
                today: '今天',
                weekSelect: '选择周',
                year: '年',
                yearFormat: 'YYYY年',
                yearSelect: '选择年份'
            },
            timePickerLocale: {
                placeholder: ''
            }
        };
        const { error, showTime, className, ...others } = this.props;
        let classNames = `${styles.datePicker}`;
        className && (classNames += ` ${className}`);
        showTime && ( classNames += ` ${styles.timePicker}`);
        error && (classNames += ` ${styles.error}`);
        return <DatePicker placeholder="" locale={locale} showTime={showTime} className={classNames} {...others} />;
    }
}

export default DatePickers;